using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace QuanLyKhachSan
{
    public class LoaiPhongBUS
    {
        // Them mot loai phong
        public static bool Insert(LoaiPhongDTO loaiPhongdto)
        {
            return LoaiPhongDAO.Insert(loaiPhongdto);
        }

        // Xoa mot doi tuong loai phong
        public static bool Delete(LoaiPhongDTO loaiPhongdto)
        {
            return LoaiPhongDAO.Delete(loaiPhongdto.MaLoaiPhong );
        }

        // Cap nhat mot doi tuong loai phong
        public static bool Update(LoaiPhongDTO loaiPhongdto)
        {
            return LoaiPhongDAO.Update(loaiPhongdto) ;
        }

        // Lay tat ca danh sach loai phong
        public static DataTable LayDanhSachLoaiPhong()
        {
            DataTable dt = new DataTable();
            dt = LoaiPhongDAO.LayDanhSachLoaiPhong();
            return dt;
        }
        public static DataTable LayDanhSachLoaiPhong1()
        {
            DataTable dt = new DataTable();
            dt = LoaiPhongDAO.LayDanhSachLoaiPhong1();
            return dt;
        }

        // Lay danh sach loai phong theo ten loai phong
        public static DataTable LayDanhSachLoaiPhongTheoTenLoaiPhong(string tenLoai)
        {
            DataTable dt = new DataTable();
            dt = LoaiPhongDAO.LayDanhSachLoaiPhongTheoTenLoaiPhong(tenLoai);
            return dt;
        }
        public static string LayMaPhongTheoTen(string tenLoaiPhong)
        {
            DataTable dt = new DataTable();
            dt = LoaiPhongDAO.LayMaPhongTheoTen(tenLoaiPhong);
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                return dr[0].ToString();
            }
            return "";
        }
        // Lay Loai phong theo don gia loai phong
        public static LoaiPhongDTO LayLoaiPhongTheoDonGia(string donGia)
        {
            DataTable dt = new DataTable();
            LoaiPhongDTO loaiPhongdto = new LoaiPhongDTO();
            dt = LoaiPhongDAO.LayLoaiPhongTheoDonGia(donGia);
            if (dt.Rows.Count > 0)
            {
                
                DataRow dr = dt.Rows[0];
                loaiPhongdto.MaLoaiPhong = int.Parse(dr["maLoaiPhong"].ToString());
                loaiPhongdto.TenLoaiPhong = dr["tenLoaiPhong"].ToString();
                loaiPhongdto.DonGia = float.Parse(dr["donGia"].ToString());
            }
            else
                loaiPhongdto.TenLoaiPhong = ""; ;
            return loaiPhongdto;
        }
        public static LoaiPhongDTO LayLoaiPhongTheoMa(int maLoai)
        {
            return LoaiPhongDAO.LayLoaiPhongTheoMa(maLoai);
        }

        public static float TongDoanhThuThang(int thang, int nam)
        {
            return LoaiPhongDAO.TongDoanhThuThang(thang, nam);
        }
        public static float DoanhThuTheoLoaiPhong(int thang, int nam, int maLoai)
        {
            return LoaiPhongDAO.DoanhThuTheoLoai(thang, nam, maLoai);
        }
    }
}
